package com.gensdai.leliang.adapter;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.gensdai.leliang.R;
import com.gensdai.leliang.view.NoScrollGridView;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;

/**
 * Created by Administrator on 2017/6/2.
 */

public class BrandListRecyclerAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {

    private LayoutInflater mLayoutInflater = null;
    private Context context;
    public List<String> data = new ArrayList<>();


    public BrandListRecyclerAdapter(Context context) {
        this.context = context;
        this.mLayoutInflater = LayoutInflater.from(context);
        data.add("1");
        data.add("1");
        data.add("1");
        data.add("1");
    }

    @Override
    public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        return new BrandViewHolder(mLayoutInflater.inflate(
                R.layout.item_brand, parent, false));
    }



    @Override
    public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {



        if(position % 2 == 0){
            List<String> list = new ArrayList<>();
            list.add("111");
            list.add("111");
            list.add("111");
            list.add("111");
            list.add("111");
            list.add("111");
            BrandContentListAdapter adapter = new BrandContentListAdapter(context);
            ((BrandViewHolder)holder).contentListBrandGrid.setAdapter(adapter);
            adapter.initAdd(list);
        }else{
            List<String> list = new ArrayList<>();
            list.add("111");
            list.add("111");
            list.add("111");
            BrandContentListAdapter adapter = new BrandContentListAdapter(context);
            ((BrandViewHolder)holder).contentListBrandGrid.setAdapter(adapter);
            adapter.initAdd(list);
        }

    }

    @Override
    public int getItemCount() {
        return data.size();
    }

    static class BrandViewHolder extends RecyclerView.ViewHolder {
        @BindView(R.id.brandParentTitle)
        TextView brandParentTitle;
        @BindView(R.id.contentListBrandGrid)
        NoScrollGridView contentListBrandGrid;

        BrandViewHolder(View view) {
            super(view);
            ButterKnife.bind(this, view);
        }
    }
}
